package xyz.erupt.flow.core.engine.formItems.Impl;

import org.springframework.stereotype.Service;
import xyz.erupt.flow.bean.entity.form.FormComponent;
import xyz.erupt.flow.core.engine.enums.FORM_ITEM_TYPE;
import xyz.erupt.flow.core.engine.formItems.WorkFlowFormItemService;
import xyz.erupt.flow.core.engine.formItems.vo.FormItemFieldVo;

import java.util.ArrayList;
import java.util.List;

/**
 * 单行文本输入处理
 */
@Service("TextInput")
public class TextInputImpl implements WorkFlowFormItemService {
    @Override
    public List<FormItemFieldVo> generateFormItemFieldVoList(FormComponent formComponent) {
        ArrayList<FormItemFieldVo> formItemFieldVos = new ArrayList<>();
        formItemFieldVos.add(FormItemFieldVo.builder()
                .id(formComponent.getId())
                .label(formComponent.getTitle())
                .defaultValue(formComponent.getValue()!=null?formComponent.getValue().toString():"")
                .type(FORM_ITEM_TYPE.STRING)
                .build());
        return formItemFieldVos;
    }
}
